<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>消费配置管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/jiujiudevice/jiuConsumeConfig/">消费配置列表</a></li>
		<li class="active"><a href="${ctx}/jiujiudevice/jiuConsumeConfig/form?id=${jiuConsumeConfig.id}">消费配置<shiro:hasPermission name="jiujiudevice:jiuConsumeConfig:edit">${not empty jiuConsumeConfig.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="jiujiudevice:jiuConsumeConfig:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="jiuConsumeConfig" action="${ctx}/jiujiudevice/jiuConsumeConfig/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="user.id"/>
		<tags:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">消费名称:</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="11" class="required"/>
			</div>
		</div>
			<div class="control-group">
			<label class="control-label">消费单价:</label>
			<div class="controls">
				<input type="number"  name="price"  value="${jiuConsumeConfig.price}" onkeyup="clearNoNum(this)"/>
			   <span style="color:grey;">单位:(元/分钟),保留两位小数</span>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="jiujiudevice:jiuConsumeConfig:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
	<script language="JavaScript" type="text/javascript"> 
    function clearNoNum(obj){ 
    obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符  
    obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的  
    obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); 
    obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数  
    if(obj.value.indexOf(".")< 0 && obj.value !=""){//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额 
        obj.value= parseFloat(obj.value); 
    } 
} 
</script>
</body>
</html>
